package com.pixiv.tools;

import org.springframework.stereotype.Component;

import java.io.File;

@Component
public class FilePragram {
    private String pragram;
    private String relativePath;
    private File fileObj;
    public FilePragram(){
        pragram = ProgramStaticGlobal.getPRealPath();
    }
    public FilePragram(String r)
    {
        pragram = ProgramStaticGlobal.getPRealPath();
        this.relativePath = r;
        fileObj = new File(pragram + "/" + r);
    }
    public void setPath(String r)
    {
        this.relativePath = r;
        fileObj = new File(pragram + "/" + r);
    }

    public boolean exist()
    {
        if (fileObj.exists() )
            return true;
        return false;
    }

    public File getFile()
    {
        return this.fileObj;
    }
    public void mkdir(String file)
    {
        File f = new File(fileObj.getAbsolutePath() + "/" + file);
        f.mkdirs();
    }

    public void close(){
        fileObj = null;
    }

}
